home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 125
/
Freelog_MarsAvril2015_No125.iso
/
Musique
/
Quod Libet
/
quodlibet-3.3.0-installer.exe
/
bin
/
quodlibet
/
mmkeys
/
__init__.pyc
(
.txt
)
next >
Wrap
Python Compiled Bytecode
|
2014-12-31
|
3KB
|
110 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.7)
from _base import MMKeysAction, MMKeysImportError
def iter_backends():
try:
GnomeBackend = GnomeBackend
MateBackend = MateBackend
import gnome
except MMKeysImportError:
pass
yield GnomeBackend
yield MateBackend
try:
KeybinderBackend = KeybinderBackend
import keybinder
except MMKeysImportError:
pass
yield KeybinderBackend
try:
PyHookBackend = PyHookBackend
import pyhook
except MMKeysImportError:
pass
yield PyHookBackend
try:
OSXBackend = OSXBackend
import osx
except MMKeysImportError:
pass
yield OSXBackend
def find_active_backend():
print_d('Trying to find a mmkeys backend')
for backend in iter_backends():
if backend.is_active():
print_d('Found %r' % backend.__name__)
return backend
class MMKeysHandler(object):
'''Manages multiple keybinding backends and translates the generated
events to actions on the player backend.
'''
def __init__(self, window, player):
self._backend = None
self._window = window
self._player = player
def start(self):
kind = find_active_backend()
if not kind:
return None
self._backend = None('Quod Libet', self._callback)
self._backend.grab()
self._window.connect('notify::is-active', self._focus_event)
def quit(self):
if self._backend:
self._backend.cancel()
self._backend = None
self._window = None
self._player = None
def _focus_event(self, window, param):
if window.get_property(param.name) and self._backend:
self._backend.grab()
def _callback(self, action):
print_d('Event %r from %r' % (action, type(self._backend).__name__))
player = self._player
if action == MMKeysAction.PREV:
player.previous()
elif action == MMKeysAction.NEXT:
player.next()
elif action == MMKeysAction.STOP:
player.stop()
elif action == MMKeysAction.PLAY:
if player.song is None:
player.reset()
else:
player.paused = False
elif action == MMKeysAction.PLAYPAUSE:
if player.song is None:
player.reset()
else:
player.paused ^= True
elif action == MMKeysAction.PAUSE:
player.paused = True
elif not 0:
raise AssertionError('unhandled event')